#ifndef BOARD_H
#define BOARD_H

#include "Field.h"
#include <vector>
#include <iostream>
#include <sstream>

class Move {
public:
	Move(){};
	Move(int f_col, int f_row, int t_col, int t_row) 
		: f_col(f_col), f_row(f_row), t_col(t_col), t_row(t_row) {};
	void set(int pf_col,int pf_row,int pt_col,int pt_row) {
		f_col = pf_col;
		f_row = pf_row;
		t_col = pt_col;
		t_row = pt_row;
	};
	int f_col;
	int f_row;
	int t_col;
	int t_row;
	std::string display() const ;
	friend std::ostream& operator<<(std::ostream& os, Move gameMove);
};

class Board {
public:
	Board();
	~Board(void);
	/** \brief Set the board with columns * rows fields.
	*/
	void setBoard(int columns, int rows);

	/** \brief Place a piece on the board.
	Non listed parameters trivial.
	@param[in] player Set the occupancy of the field to player.
	*/
	bool placePiece(int column,int row, int player);

	/** \brief Moves from one field to another
	This function moves a piece from one tile to another and leaving
	from tile as empty.
	*/
	void movePiece(const Move &gameMove);

	/** \brief Returns the occupancy of selected field.
	*/
	int getOccupancy(int column, int row);

	// TODO keep this function auto updated with board changes.
	/** \brief Counts the player pieces
	return values are pl1 and pl2 for player 1 and player 2 respectively.
	NOTE parameters pl1 and pl2 are changed!
	*/
	void countPieces( int &pl1, int &pl2); 

	// TODO maybe pair vector allocated from heap?
	void getPlayerPieces(int player, std::vector<std::pair<int,int> >& pieces);

	// TODO Make game class hold board size.
	int getColumnSize(); /**< Returns the number of columns */
	int getRowSize();	/**< Returns the number of rows */

	friend std::ostream& operator<<(std::ostream& os, Board& board);

private:
	std::vector< std::vector<Field*> > m_fields;
	bool m_boardChanged;
	int m_columns;
	int m_rows;

};

#endif //BOARD_H